package com.unicorn.util.common;

import com.unicorn.base.VinaceConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by user on 2016/12/3.
 */
@Component
public class FileComponent  extends BaseComponent{




    private String rootPath=this.getVinaceConfig().ONLINE_FILE_SYSTEM_ROOT ;
    private   String currentPath = "./";

    public List<File> listFiles(String filePath) {
        if (filePath == null) {
            filePath = rootPath;
        }
        if ("".equals(filePath)) {
            filePath = currentPath;
        }
        File baseDir = new File(filePath);
        File[] files = baseDir.listFiles();
        if (files == null) {
            return new ArrayList<File>();
        }
        return Arrays.asList(baseDir.listFiles());
    }

}
